<!--
 * @Author: Lcx l1556461835@163.com
 * @Date: 2022-11-18 14:22:56
 * @LastEditors: YXP 2426061097@qqcom
 * @LastEditTime: 2023-04-24 16:58:02
 * @FilePath: \AFadminSystem\src\views\PersonMsg\ApkVersionMsg.vue
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<template>
	<div>
		<el-button @click="addForm">记录列表</el-button>
		<el-table
		  :data="tableData"
		  style="width: 100%">
		  <el-table-column
			prop="appName"
			label="用户名"
			width="180">
		  </el-table-column>
		  <el-table-column
			prop="version"
			label="用户ID"
			width="180">
		  </el-table-column>
		  <el-table-column
			prop="createTime"
			label="登录日期">
		  </el-table-column>
		  <el-table-column
			prop="updateContent"
			label="登录记录">
		  </el-table-column>
		  <el-table-column
			prop="wtgUrl"
			label="访问路径">
		  </el-table-column>
		</el-table>
		
		<!-- 弹窗新增 -->
		<el-dialog
		  title="记录列表"
		  :visible.sync="dialogVisible"
		  width="50%">
		  <el-form :inline="true" :model="dialogForm">
		    <el-form-item label="用户名">
		      <el-input v-model="dialogForm.appName" placeholder="用户名"></el-input>
		    </el-form-item>
			<el-form-item label="用户ID">
			  <el-input v-model="dialogForm.version" placeholder="用户ID"></el-input>
			</el-form-item>
			<el-form-item label="登录时间">
			  <el-input v-model="dialogForm.updateContent" placeholder="登录时间"></el-input>
			</el-form-item>
			<el-form-item label="选择文件">
			  <input type="file" @change="handleChange($event)">
			</el-form-item>
		  </el-form>
		  <span slot="footer" class="dialog-footer">
		    <el-button @click="dialogVisible = false">取 消</el-button>
		    <el-button type="primary" @click="submit">确 定</el-button>
		  </span>
		</el-dialog>
	</div>
</template>

<script>
	export default {
		data() {
			return {
				page: 1,
				size: 100,
				tableData: [],
				dialogVisible: false,
				dialogForm: {
					appName: '',
					version: '',
					updateContent: '',
				},
				files: {}
			}
		},
		mounted() {
			this.getAllApk()
		},
		methods: {
			async getAllApk() {
				let res = await this.$post("/apk/findAll", {
					page: this.page,
					size: this.size,
				})
				console.log('所有的用户记录==', res);
				this.tableData = res.data
			},
			addForm() {
				this.dialogVisible = true
			},
			handleChange(e) {
				let ev = window.event || e // change获得的内容
				console.log(ev)
				this.files = ev.target.files[0]
			},
			async submit() {
				let formData = new FormData();
				formData.append("files", this.files)
				formData.append('apkVersion', this.dialogForm)
				for (let param in this.dialogForm) {
					formData.append(param, this.dialogForm[param])
				}
				let res = await this.$post("/apk/upload", formData)
				console.log("res",res);
				if(res.code==0)
				{
					 this.dialogVisible = false
					 this.getAllApk()
				}
				
			}
		}
	}
</script>

<style>
</style>